package com.jifeng.api.crud.controller;

import java.util.Arrays;
import java.util.Map;

import com.jifeng.api.crud.entity.VwOrderUserEntity;
import com.jifeng.api.crud.service.VwOrderUserService;
import com.jifeng.api.utils.PageUtils;
import com.jifeng.api.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * VIEW
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-10-10 20:52:17
 */
@RestController
@RequestMapping("crud/orderuser")
public class VwOrderUserController {
    @Autowired
    private VwOrderUserService vwOrderUserService;

    /**
     * 查询订单列表
     */
    @GetMapping("/pc/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = vwOrderUserService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 导出现金明细表
     */
    @GetMapping("/cash/detail/export")
    public R exportCash(HttpServletResponse response, @RequestParam Map<String, Object> params){
        R rs= vwOrderUserService.exportCash(response,params);
        return rs;
    }

    /**
     * 导出现金统计表
     */
    @GetMapping("/cash/summary/export")
    public R exportCashSummary(HttpServletResponse response, @RequestParam Map<String, Object> params){
        R rs= vwOrderUserService.exportCashSummary(response,params);
        return rs;
    }

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		VwOrderUserEntity vwOrderUser = vwOrderUserService.getById(id);

        return R.ok().put("vwOrderUser", vwOrderUser);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody VwOrderUserEntity vwOrderUser){
		vwOrderUserService.save(vwOrderUser);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody VwOrderUserEntity vwOrderUser){
		vwOrderUserService.updateById(vwOrderUser);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		vwOrderUserService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
